//	@file Version: 1.0
//	@file Name: ADP_F_fillItems.sqf
//	@file Author: THumbert
//	@file Created: 12/14/2013
//	@file Description: Fills listbox with Items

#define ARRAYCHECK(a,b) [##a,##b] call {_veh = _this select 0;_types = _this select 1;_res = false; {if (_veh isKindOf _x) exitwith { _res = true };} forEach _types;_res}

disableSerialization;
_disp = _this select 0;
_control = _this select 1;
_type = _this select 2;
_display = findDisplay _disp;
_ctrl = _display displayctrl _control;
_Listbox = _control;
_kindOf = ["Bag_base"];
_filter = ["Uniform_Base"];
lbClear _Listbox;
hint "Adding Items";
_cfgWeapons = configFile >> "cfgWeapons";
_cfgvehicles = configFile >> "cfgVehicles";
for "_i" from 0 to (count _cfgvehicles)-1 do {
	_vehicle = _cfgvehicles select _i;
	if (isClass _vehicle) then {
		_veh_type = configName(_vehicle);
		if ((getNumber(_vehicle >> "scope")==2)and(getText(_vehicle >> "picture")!="")and(ARRAYCHECK(_veh_type,_kindOf))) then {
			_Text = (getText(_vehicle >> "displayName"));
			_index = lbAdd [_ListBox, _Text];
			lbSetData [_listbox,_index,_veh_type];
			lbSetPicture [_listbox,_index,getText(_vehicle >> "picture")];
			lbSetValue [_listbox, _index,_type];
		};
	};
};
_weaponInfo = {((getNumber(_this >> "scope")==2)&&(getNumber(_this >> "access")!=0)&&(getText(_this >> "model")!="")&&(getText(_this >> "displayName")!=""))};
_isWeapon = {(_this call _weaponInfo)&&(getNumber(_this >> "type") in [131072,50])};
_type = 6;
for "_i" from 0 to (count _cfgweapons)-1 do {
			_weapon = _cfgweapons select _i;
			if (isClass _weapon) then {
				if (_weapon call _isWeapon) then {
					if(getNumber(_weapon >> "ItemInfo" >> "type")==0) then {_type = 6;};/* Small Items */
					if(getNumber(_weapon >> "ItemInfo" >> "type") in [701,801,605,619, 607, 401])then {_type = 7;};/* Uniforms */
					if(getNumber(_weapon >> "ItemInfo" >> "type") in [201, 301, 101]) then {_type = 8;};/* Weapon Attachments */
					_index = lbAdd [_listbox, getText(_weapon >> "displayName")];
					lbSetData [_listbox, _index,configName _weapon];
					lbSetPicture [_listbox, _index,getText(_weapon >> "picture")];	
					lbSetValue [_listbox, _index,_type];
				};
			};
};	
lbsort _ctrl;